import axios from 'axios';
import qs from 'query-string';

export interface PayPingId {
    id: number;
}

export interface PayPingRecord {
    id: number;
    user_id: number;
    order_id: number;
    biz_id: number;
    content: string;
    star: number;
    images: string;
    biz_reply?: string;
    system_reply?: string;
    type_name: string;
    item_id: number;
    goods_name?: string;
    created_at: string;
    user?: {
        id: number;
        nickname: string;
        phone: string;
    };
    order?: {
        id: number;
        order_no: string;
    };
    biz?: {
        id: number;
        name: string;
    };
}

export interface PayPingListRes {
    list: PayPingRecord[];
    total: number;
}

export interface PayPingModel {
    id: number;
}

export interface PayPingParams extends Partial<PayPingRecord> {
    current: number;
    pageSize: number;
}

/**
 * 获取点评列表
 * @param params
 */
export function queryPayPingList(params: PayPingParams) {
    return axios.get<PayPingListRes>('/admin/payPing/index', {
        params,
        paramsSerializer: (obj) => {
            return qs.stringify(obj);
        },
    });
}

/**
 * 获取点评详情
 * @param params
 */
export function queryPayPingOne(params: PayPingId) {
    return axios.get<PayPingRecord>('/admin/payPing/detail', {
        params,
        paramsSerializer: (obj) => {
            return qs.stringify(obj);
        },
    });
}

/**
 * 删除点评
 * @param id
 */
export function delPayPing(id: number) {
    return axios.post('/admin/payPing/delete', { id });
}

/**
 * 商家回复
 * @param id
 * @param reply
 */
export function bizReply(id: number, reply: string) {
    return axios.post('/admin/payPing/bizReply', { id, reply });
}

/**
 * 平台回复
 * @param id
 * @param reply
 */
export function systemReply(id: number, reply: string) {
    return axios.post('/admin/payPing/systemReply', { id, reply });
} 